package ar.edu.uba.fi.jmit.graphvisualizer.server.mock;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import ar.edu.uba.fi.jmit.graphvisualizer.client.AlertService;
import ar.edu.uba.fi.jmit.graphvisualizer.shared.AlertInfo;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class AlertServiceMock extends RemoteServiceServlet implements AlertService {

	private static final long serialVersionUID = -4473508290340064015L;

	@Override
	public List<AlertInfo> getLastReceivedAlerts() {
		List<AlertInfo> list = new LinkedList<AlertInfo>();
		for(int i = 0; i < 15; i++) {
			list.add(this.createNewAlertInfo(i));
		}
		return list;
	}

	private AlertInfo createNewAlertInfo(int i) {
		AlertInfo alertInfo = new AlertInfo();
		alertInfo.setAlertTime(SimpleDateFormat.getInstance().format(new Date()));
		alertInfo.setApplication("Mock Application1");
		alertInfo.setMonitor("Monitor" + i);
		alertInfo.setMessage("This is a message for the alert Number " + i);
		alertInfo.setSeverity("Not much, just a Mock Alert");
		return alertInfo;
	}

}
